<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="_token" content="{{ csrf_token() }}"/>
    <title>上海宏邦知识产权代理有限公司</title>
    <link rel="Shortcut Icon" href="{{asset('admin_assets/img/HB.ico') }}"/>
    <link rel="Bookmark" href="{{asset('admin_assets/img/HB.ico') }}" />
    <link rel="stylesheet" type="text/css" href="{{asset('admin_assets/css/bootstrap.min.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('admin_assets/css/font-awesome/css/font-awesome.min.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('admin_assets/css/AdminLTE.min.css')}}">
    <style>
        html body {
            margin: 0;
            height: 100%;
        }
        #body {
            width: 100%;
            height: 100%;
            overflow-x: hidden;
            overflow-y: hidden;
            position: relative;
        }

        .clear {
            clear: both
        }

        #header {
            width: 100%;
            height: 60px;
            border-bottom: solid 1px #00a6ff;
            position: fixed;
            top: 0;
        }

        #header-left {
            width: 50%;
            height: 100%;
            min-width: 250px;
            font-size: 20px;
            color: #676767;
            float: left;
        }

        #header-left p {
            margin-top: 16px;
            margin-left: 30px;
        }

        #header-right {
            width: 50%;
            height: 100%;
            min-width: 120px;
            font-size: 20px;
            color: #676767;
            float: right;
        }

        #header-right p {
            font-size: 14px;
            text-align: right;
            margin-right: 10px;
            margin-top: 18px;
            min-width: 125px;
            color: #676767;
        }

        #header-right p a {
            color: #676767;
        }

        #content {
            width: 100%;
            margin-top: 60px;
        }

        #steps {
            height: 48px;
            border-bottom: 2px solid #e6e6e6;
            position: relative;
        }

        #steps ul {
            width: 500px;
            margin: 0 auto;
        }

        .span-title {
            list-style: none;
            width: 150px;
            line-height: 46px;
            text-align: center;
            float: left;
            font-size: 16px;
            color: #999;
        }

        .active {
            border-bottom: solid 2px #0080ff;
        }

        .content-title {
            text-align: center;
            margin-top: 2%;
            font-size: 16px;
            color: #676767;
        }

        .phone-input {
            margin: 1% auto;
            width: 25%;
            border-radius: 5px;
        }

        .code-input {
            width: 23%;
            float: right;
            border-radius: 5px;
        }

        .click-btn {
            float: left;
            border-radius: 5px;
            width: 23%;
            height: 34px;
            border: none;
            outline: none;
            color: black;
        }

        #btn-confirm {
            width: 25%;
            height: 34px;
            border: none;
            border-radius: 5px;
            background: #0080ff;
            color: white;
            outline: none;
            margin-top: 1%;
            margin-left: 37.5%;
        }

        #footer {
            width: 100%;
            margin: 0;
            position: fixed;
            bottom: 0;
            height: 120px;
        }

        #footer_title {
            width: 100%;
            text-align: center;
            bottom: 5px;
            position: fixed;
            color: #a8a8a9;
        }
        .error{
            color: #d90003;
            margin-left: 38%;
            display: none;
        }
    </style>
</head>
<body>
<div id="body">
    <div id="header">
        <div id="header-left"><p>IP管理系统</p></div>
        <div id="header-right"><p><a href="{{url('/')}}">立即登录</a></p></div>
    </div>
    <div id="content">
        <div class="row" style="margin-top: 4%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <h4 style="font-size: 20px"><i class="fa fa-edit fa-lg" style="color: #0080ff"></i>&nbsp;&nbsp;忘记密码</h4>
            </div>
        </div>
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2" id="steps">
                <ul>
                    <li class="span-title active"><b>验证手机</b></li>
                    <li class="span-title"><b>设置密码</b></li>
                </ul>
            </div>
        </div>
        <div class="row" style="margin-top: 3%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <p class="content-title"><b>验证手机</b></p>
            </div>
        </div>
        <form action="{{url('user/forgetPassword/forgetPasswordReset')}}" method="post" enctype="multipart/form-data">
        {{csrf_field()}}
            <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <input type="text" id="tel" name="tel" class="form-control phone-input" placeholder="手机号" onblur="check_tel();">
            <span id="error_empty_tel" class="error">
                                <i class="fa fa-times-circle"></i>请输入手机号码</span>
                            <span id="error_type_tel" class="error">
                                <i class="fa fa-times-circle"></i>手机号格式错误</span>
                            <span id="error_existence_tel" class="error">
                                <i class="fa fa-times-circle"></i>该手机号不存在</span>
            </div>
        </div >
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <div class="row">
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                        <input type="text" id="put_code" name="put_code" class="form-control code-input" placeholder="验证码" onblur="check_code();">
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                        <input id="tel_verification_code" type="button" value="获取验证码" class="click-btn">
                        <input id="hide_verification_code" type="hidden" name="hide_verification_code">
                    </div>
                    <span id="error_empty_code" class="error">
                                <i class="fa fa-times-circle"></i>验证码为空</span>
                    <span id="error_code" class="error">
                                <i class="fa fa-times-circle"></i>验证码错误</span>
                </div>
            </div>
        </div>
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <button id="btn-confirm" type="submit">确定</button>
            </div>
        </div>
        </form>
    </div>
    <div id="footer">
        <p id="footer_title">Copyright &copy; 2018 <a style="color: #A8A8A9" href="http://www.hongbung.com" target="_blank">上海宏邦知识产权代理有限公司</a></p>
    </div>
</div>
<script src="{{asset('admin_assets/js/jquery.min.js')}}"></script>
<script src="{{asset('admin_assets/js/bootstrap.min.js')}}"></script>
<script src="{{asset('js/ip.js')}}"></script>
<script>
    var res;
    var wait=60;
    function time(o) {
        if (wait == 0) {
            o.attr('disabled',false);
            o.attr("value","点击重发验证码");
            wait = 60;
        } else {
            o.attr('disabled',true);
            o.attr('value',"重发验证码"+"("+wait+"s)");
            wait--;
            setTimeout(function () {
                time(o)
            }, 1000);
        }
    }
    $("#tel_verification_code").click(function () {
        var text =$("#tel").val();
        if(text!=""){
            time($("#tel_verification_code"));
            $.ajax({
                url:'{{url('user/register/get_tel_code')}}',
                data: {'phoneNumber': text},
                type: 'post',
                dataType: "json",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success:function (data) {
                    console.log(data);
                    $("#hide_verification_code").attr('value',data['data']['identifyingCode']);
                },
                error:function () {
                    console.log(-1);
                    return false;
                }
            });
        }else{
            alert("手机号码为空")
        }
    });
    function check_tel() {
        var reg = /^1[3|4|5|7|8][0-9]{9}$/;
        var tel = $("#tel").val();
        var flag = reg.test(tel);
        if (tel == '') {
            $("#error_empty_tel").css('display', 'block');
            $("#error_type_tel").css('display', 'none');
            $("#success_tel").css('display', 'none');
            $("#btn-confirm").attr("disabled", true);
            res = false;
            return res;
        } else if (!flag) {
            $("#error_empty_tel").css('display', 'none');
            $("#success_tel").css('display', 'none');
            $("#error_type_tel").css('display', 'block');
            $("#btn-confirm").attr("disabled", true);
            res = false;
            return res;
        } else {
            $.ajax({
                url: "{{url('user/forgetPassword/ajaxCheckTel')}}",
                type: 'post',
                dataType: "json",
                headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')},
                data: {'tel': tel},
                success: function (data) {
                    console.log(data);
                    if (data == 1) {
                        $(".error").css('display', 'none');
                        $("#error_existence_tel").css('display', 'block');
                        $("#btn-confirm").attr("disabled", true);
                    } else {
                        $(".error").css('display', 'none');
                        $("#btn-confirm").attr("disabled", false);
                        res = true;
                        return res;
                    }
                }
            });
        }
    }
    function check_code() {
        var put_code=$("#put_code").val();
        var check_code=$("#hide_verification_code").val();
        if(put_code.length==0){
            $(".error").css('display','none');
            $("#error_empty_code").css('display','block');
            $("#btn-confirm").attr("disabled", true);
        }
        else if(put_code!=check_code){
            $(".error").css('display','none');
            $("#error_code").css('display','block');
            $("#btn-confirm").attr("disabled", true);
        }else {
            $(".error").css('display','none');
            $("#btn-confirm").attr("disabled", false);
        }
    }
</script>
</body>
</html>
